home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / netlib / sleep.c < prev    next >
C/C++ Source or Header  |  1994-04-04  |  2KB  |  66 lines

  1. RCS_ID_C="$Id: sleep.c,v 1.1 1994/04/04 01:30:50 jraja Exp $"
  2. /*
  3.  * sleep.c -- suspend process for the specified time
  4.  *
  5.  * Author: jraja <Jarno.Rajahalme@hut.fi>
  6.  *
  7.  * Copyright © 1994 AmiTCP/IP Group, <amitcp-group@hut.fi>
  8.  *                  Helsinki University of Technology, Finland.
  9.  *                  All rights reserved.
  10.  *
  11.  * Created      : Mon Apr  4 00:30:12 1994 jraja
  12.  * Last modified:
  13.  *
  14.  * $Log: sleep.c,v $
  15.  * Revision 1.1  1994/04/04  01:30:50  jraja
  16.  * Initial revision
  17.  *
  18.  */
  19.  
  20. #include <sys/param.h>
  21. #include <unistd.h>
  22. #include <sys/time.h>
  23. #include <sys/socket.h>
  24.  
  25. /****** net.lib/sleep *********************************************
  26.  
  27.     NAME
  28.     sleep - suspend process execution for the specified time
  29.  
  30.     SYNOPSIS
  31.     void sleep(unsigned int seconds);
  32.  
  33.     FUNCTION
  34.         Process execution is suspended for number of seconds specified in 
  35.         'seconds'. The sleep will be aborted if any of the break signals
  36.         specified for the process is received (only CTRL-C by default).
  37.  
  38.     PORTABILITY
  39.     UNIX
  40.  
  41.     INPUTS
  42.     'seconds' - number of seconds to sleep.
  43.  
  44.     RESULT
  45.         Does not return a value.
  46.  
  47.     NOTES
  48.         The sleep is implemented as a single select() call with all other
  49.         than time out argument as NULL.
  50.  
  51.     SEE ALSO
  52.     bsdsocket.library/select()
  53.  
  54. *****************************************************************************
  55. *
  56. */
  57.  
  58. void sleep(unsigned int secs)
  59. {
  60.   struct timeval tv;
  61.  
  62.   tv.tv_sec = secs;
  63.   tv.tv_usec = 0;
  64.   select(0, 0, 0, 0, &tv);
  65. }
  66.